<?php

namespace backend\models;

use Yii;
use yii\helpers\ArrayHelper;
use yii\db\ActiveRecord;
use backend\models\Image;
class Vr extends \yii\db\ActiveRecord
{
    public static $vr_flag = ['0'=>'没有vr','1'=>'有vr'];
    public static $app_return=['0'=>'下架','1'=>'上架'];
    public $image_upload;
    /**
     * @inheritdoc
     */
    public static function tableName()
    {
        return 'vr';
    }

    /**
     * @inheritdoc
     */
    public function rules()
    {    	
        return [
            [['id', 'createtime','vr_img','vr_flag','app_return'], 'integer'],
            [['name', 'city','village','house_type'], 'required'],
            [['name','city','village','house_type','cost'], 'string', 'max' => 20],
            [['vr_url','area','brief' ], 'string'],
            [[ 'desc'],'safe'],
            [['image_upload'], 'image','extensions' => 'png,jpg,jpeg,gif,bmp','maxWidth'=>'2000','maxHeight'=>'5000',
                'overWidth'=>'宽必须低于2000像素','overHeight'=>'高必须低于5000像素'],

        ];
    }
    /**
     * @inheritdoc
     */
    public function attributeLabels()
    {
        return [
            'id' => 'ID',
            'createtime' => '创建时间',
            'name' => Yii::t('app','名称'),
            'city' => Yii::t('app','城市'),
            'village' => Yii::t('app','小区'),
            'house_type' => Yii::t('app','户型'),
            'vr_url' => Yii::t('app','vr路径'),
            'vr_img' => Yii::t('app','主图'),
            'desc' => Yii::t('app','图文详情'),
            'image_upload'=>Yii::t('app','vr主图上传'),
            'area'=>'面积',
			'cost'=>'软装花费',
            'brief'=>'副标题',
            'vr_flag'=>'vr标志',
            'app_return'=>'是否上架'
        ];
    }
    public function getImg()
    {
        return $this->hasOne(Image::className(), ['id' => 'vr_img']);
    }

    public function getDefaultSmallImage()
    {
        return $this->hasOne(Image::className(),['id'=>'vr_img'])->from(['mainVrImgS'=>Image::tableName()]);
    }
}
